import HttpClient from '../../utils/httpClient';

export function resourceTree(success, error) {
  HttpClient.request({
    url: '/resource/tree',
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function menuTree(success, error) {
  HttpClient.request({
    url: '/resource/menu',
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function createResource(data, success, error) {
  HttpClient.request({
    method: 'post',
    url: '/resource/create',
    data,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function resourceDetail(id, success, error) {
  HttpClient.request({
    url: `/resource/detail/${id}`,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function updateResource(id, data, success, error) {
  HttpClient.request({
    method: 'put',
    url: `/resource/update/${id}`,
    data,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function deleteResource(id, success, error) {
  HttpClient.request({
    method: 'delete',
    url: `/resource/delete/${id}`,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}
